#ifndef PSC_CLASSC_FILESENDER_H
#define PSC_CLASSC_FILESENDER_H
#include <cstddef>
#include <string>
#include <mutex>
#include <condition_variable>
#include <atomic>

class FileSender {
public:
    FileSender(const std::string& file_path, const std::string& dest_ip, int dest_port, int local_port = 0);
    void sendUDP();
    void sendUDP(int file_id); // 新增，带文件编号
    void sendTCP();
    // 新增：监听指令
    static void waitForCommand();
    // 新增：同步机制
    static std::mutex mtx_;
    static std::condition_variable cv_;
    static std::atomic<bool> start_signal_;
    static std::atomic<bool> abort_signal_;
private:
    std::string file_path_;
    std::string dest_ip_;
    int dest_port_;
    int local_port_;
    unsigned char* buffer_;
    size_t filesize_;
    void loadFile();
};

#endif // PSC_CLASSC_FILESENDER_H 